#define _CRT_SECURE_NO_WARNINGS 1

#include <stdio.h>

int is_leap(long long years)
{
    return ((years % 4 == 0 && years % 100 != 0) || years % 400 == 0);
}

int main()
{
    long long timestamp = 0;
    scanf("%lld", &timestamp);

    long long days = timestamp / 86400;
    int day = 0;
    int year = 1970;
    int month = 0;
    int hour = timestamp % 86400 / 3600;
    int min = timestamp % 86400 % 3600 / 60;
    int second = timestamp % 86400 % 3600 % 60;
    while (1)
    {
        int days_in_year = is_leap(year) ? 366 : 365;
        int days_in_month[] = { 31,28,31,30,31,30,31,31,30,31,30,31 };
        if (is_leap(year))
            days_in_month[1] = 29;
        if (days >= days_in_year)
        {
            days -= days_in_year;
            year++;
        }
        else
        {
            while (days + 1 > days_in_month[month])
            {
                days -= days_in_month[month];
                month++;
            }
            month++;
            day = days + 1;
            break;
        }
    }

    printf("%4d-%02d-%02d %02d:%02d:%02d", year, month, day, hour, min, second);
    return 0;
}